package cn.usian.controller;

import cn.usian.pojo.User;
import cn.usian.service.UserService;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

@CrossOrigin
@RequestMapping("/user")
@RestController
public class UserController {
    @Resource
    private UserService userService;

    //全查
    @GetMapping("/findAll")
    public List<User> findAll(){
        return userService.findAll();
    }

    //添加
    @RequestMapping("/add")
    public void add(@RequestBody User user){
        userService.add(user);
    }

    //删除
    @GetMapping("/del")
    public void del(String id){
        userService.del(id);
    }

    //回显
    @RequestMapping("/findById")
    public User findById(String id){
        return userService.findById(id);
    }

    //修改
    @RequestMapping("/update")
    public void update(@RequestBody User user){
        userService.update(user);
    }
}
